<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script type="text/JavaScript">
	var grid;
	$(function() {
		 //分类管理表格  
		 grid = $('#reportgrid').datagrid({
         url:'listMyReport.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true, 
         striped: true,  
         singleSelect : true,  
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
         columns:[[  
             {field:'reportid',title: 'ID',align: 'center',width: '50'},  
             {field:'name',title: '周报名称',align: 'center',width: '250'},
             {field:'starttime',title: '开始时间',align: 'center',width: '150'},
             {field:'stoptime',title: '结束时间',align: 'center',width: '150'},
             {field:'zt',title: '状态',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
             		if(value == '0'){
             			str = "未发送";
             		}else if(value == '1'){
             			str = "已发送";
             		}
					return str;
				}
             },
             {field:'action',title: '操作',align: 'center',width: '150',
             	formatter: function(value,rowdata,index){
             		var str = '';
					str += '<a id="btnadd" class="l-btn l-btn-plain" target="_blank" href="${request.contextPath}/xadmin/work/workReportDownLoad.do?reportid='+rowdata.reportid+'"><span class="l-btn-left"><span class="l-btn-text icon-redo l-btn-icon-left" >下载</span></span></a>';
					return str;
				}
             }]],
             toolbar : '#toolbar'
     });
});
	function doAdd() {
		var modalwindow = window.top.modalwindow('${request.contextPath}/xadmin/work/workReportWindow.do',$('#reportgrid'),{    
		    width:950,    
		    height:550,
		    modal:true,
		    resizable:true,
		    title:'新增周报信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj('');
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	function doEdit() {
		var selected = $('#reportgrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		var modalwindow =  window.top.modalwindow('${request.contextPath}/xadmin/work/workReportWindow.do?reportid='+selected.reportid,$('#reportgrid'),{    
		    width:950,    
		    height:550,
		    modal:true,
		    resizable:true,
		    title:'修改周报信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj(selected.reportid);
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	//工具栏删除
	function doDel(){
		var selected = $('#reportgrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		window.top.$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("${request.contextPath}/xadmin/work/delWorkReport.do", { "reportid": selected.reportid},
				   function(data){
				   	$('#reportgrid').datagrid('reload'); 
				   	window.top.$.messager.alert('提示',data);
				   	
				});
			}
		});
	}
	function shenheReport(id,result){
		if(result == 0){
			result = 1;
		}else{
			result = 0;
		}
		$.post("shenheReport.do", { "docid": id,"result":result},
		   	function(data){
		   		$('#reportgrid').datagrid('reload'); 
		   		window.top.$.messager.alert('提示',data);
		});
	}
	//
	function doReload(){
		$('#toolbar input').val('');
		grid.datagrid('reload',{});
	}
	//
	function doSearch(){
		var params = {};
		if($('#starttime').datebox('getValue')){
			params['starttime'] = $('#starttime').datebox('getValue');
		}
		if($('#stoptime').datebox('getValue')){
			params['stoptime'] = $('#stoptime').datebox('getValue');
		}
		grid.datagrid('reload',params);
	}	
</script>

</head>
<body>
	<table id="reportgrid" data-options="fit:true,border:false"></table>
	<div id="toolbar" style="display: none;">
<table border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td valign="center">
	&nbsp;开始日期：	<input class="easyui-datebox" type="text" id="starttime" name="starttime" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">
	&nbsp;结束日期：<input class="easyui-datebox" type="text" id="stoptime" name="stoptime" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">	
	<a href="javascript:doSearch();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索</a>
	</td>
	<td valign="center">
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	</td>
	<td valign="center">
	<a href="javascript:doReload();" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	<td valign="center" align="left">
	<a href="javascript:doAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
	</td>
	<td valign="center" align="left">
	<a href="javascript:doEdit();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
	</td>
	<td valign="center" align="left">
	<a href="javascript:doDel();" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">删除</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
</tr>
</table>
</body>
</html>